
public class question3 {
	
	public static void main (String[] args){
		int[] S = {4,5};
		int n = 13;
		System.out.println(f(n,S));
		System.out.println(f(6,S));
	}
	
	static boolean f(int n, int[] S) {
		int index = 0;
		return isSumOf(n,S,index );
		}

	static boolean isSumOf(int n, int[] S, int i) {

			if (n == 0 ){
				return true;
			}
			
			if (n < 0){
				return false;
			}
			
			n = n - S[i];
			return isSumOf(n,S,i) || isSumOf(n,S,i + 1);
	}

}
